package com.lu.bio.server;

import cn.hutool.core.util.CharsetUtil;
import com.lu.GlobalConfig;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @program lu-netty
 * @description:
 *  - 请求:线程 = 1:1
 * @author: zhanglu
 * @create: 2022-06-09 14:41:00
 */
@Slf4j
public class BioServer {

    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket();
            serverSocket.bind(new InetSocketAddress(GlobalConfig.LOCAL_PORT));
            log.info("BioServer start...");
            while (true){
                Socket socket = serverSocket.accept();
                BioServerHandler serverHandler = new BioServerHandler(socket, CharsetUtil.UTF_8);
                serverHandler.start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
